fix(android): resolve black screen and improve reliability#5
Closed
fix(android): resolve black screen and improve reliability#5
Conversation
Replace Thread.sleep(1000) on UI thread with Handler.postDelayed to prevent ANR and rendering failures. Fix _isUnityReady flag being set when player creation fails. Fix broken setZ reflection (missing float parameter) that prevented background Z-ordering. Add null-safety for requestFrame() results. Fix pauseUnity ignoring the pause parameter. Replace silent catch blocks with Log statements for debuggability. Remove hardcoded Google Maps API key from example app. Closes #3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix multiple Android-side bugs that cause black screen and silent failures in Unity player initialization.
Why
Issue #3 reports a black screen. Root cause analysis found 6 interacting bugs:
Thread.sleep(1000)on UI thread blocks rendering and risks ANR_isUnityReadyset totrueeven when UPlayer creation throws —isUnityReady()returns true butgetPlayer()returns nullUPlayer.setZ()uses broken reflection (getMethod("setZ")withoutfloat.classparam) — the Z-index call to push background Unity view behind React content always silently failsrequestFrame()can return null but callers never check — NPE crash or silent failurepauseUnity(view, pause)ignores thepauseboolean and always pausesHow
Thread.sleep(1000)withHandler.postDelayed()— same 1s delay but non-blocking_isUnityReadyonly set on successsetZ()to callframe.setZ()directly instead of broken reflectionrequestFrame()in bothaddUnityViewToBackgroundandaddUnityViewToGrouppauseUnityto respect the boolean parameter (pause vs resume)Log.e/Log.wfor debuggabilityHandler()constructor →Handler(Looper.getMainLooper())Testing
No test suite exists for native code. Changes are mechanical (null guards, logging, correct API usage) and don't alter the initialization sequence — only fix silent failures within it. Manual testing on Android device with Unity project recommended.
🤖 Generated with Claude Code
Quality Report
Changes: 5 files changed, 95 insertions(+), 44 deletions(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline